#ifndef		ICOMMUNICATOR_HPP_
# define	ICOMMUNICATOR_HPP_

# include	<sstream>
# include	<iostream>
# include	<list>

# include	"Control.hpp"
# include	"Buffer.hpp"
# include	"IATcp.hpp"
# include	"FdInfos.hpp"
# include	"Connected.hpp"

class ACommunicator
{
protected:
  IATcp		*Tcp;
  Control	Ctl;
  
  int		FdSocket;
  FdInfos	FdInfo;
  TimeVal	Tim;

  int		Port;

  int		InitFd();
  int		OpenSocket();

public:
  ACommunicator(int	port);
  virtual ~ACommunicator();

  virtual int TraitementBuf();
  virtual int	CheckIsComplete(Connected	&Co,
				int		fd);
  virtual int	TryToWrite(std::list<Buffer *> &writeBuf,
			   int fd);
  virtual int	TryToRead(Buffer &readBuf,
			  int fd);
};

template <typename T>
T	to(const std::string    &str)
{
  std::istringstream	iss(str);
  T			i;

  iss >> i;
  return (i);
}

#endif		/* ICOMMUNICATOR_HPP_ */
